<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>客户股票操作记录</title>
		<link rel="stylesheet" href="__PUBLIC__/frame/layui/css/layui.css">
			<!--<link rel="stylesheet" href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">-->
		<link rel="stylesheet" href="__PUBLIC__/frame/static/css/style.css">
	</head>
	<body>
		<a href="<?php echo U('Service/moreInfo?id='.$cus_id);?>"><button class="layui-btn" style="margin-top: 10px;"><i class="layui-icon">&#xe603;</i>客户详情</button></a>
    	<a class="layui-btn btn-add btn-default" id="btn-refresh" style="margin-top: 10px;"><i class="layui-icon">&#x1002;</i></a>
    	<table class="layui-table" border="" cellspacing="" cellpadding="" width="100%">
    		<thead>
    			<tr>
    				<td width="10%">股票代码</td>
    				<td width="10%">股票名称</td>
            <td width="10%">操作价格</td>
    				<td width="10%">操作数量</td>
    				<td width="10%">推荐来源</td>
    				<td width="17%">添加时间</td>
            <td width="18%">更新时间</td>
    				<td width="15%">操作</td>
    			</tr>
    		</thead>
            <tbody>
<?php foreach ($list as $k => $v):?>
            	<tr>
            		<td><?php echo $v['stock_code'];?></td>
            		<td><?php echo $v['stock_name'];?></td>
                <td><?php echo $v['sale_price'];?></td>
            		<td><?php echo $v['position_num'];?></td>
            		<td><?php echo $v['source'];?></td>
            		<td><?php echo date('Y-m-d H:i',$v['addtime']);?></td> 
                <td><?php echo date('Y-m-d H:i',$v['updatetime']);?></td>           		
            		<td>            		 
                <a href="<?php echo U('Position/edit?id='.$v['id'].'&p='.I('get.p')); ?>" class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
    					  <a href="<?php echo U('Position/delete?id='.$v['id'].'&p='.I('get.p')); ?>" id="defriend" class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del" cus_id="<?php echo $v['id'];?>" status="<?php echo $v['status'];?>">删除</a>
            		</td>
            	</tr>
<?php endforeach;?> 
            </tbody>
    	</table>
	</body>
</html>
<script type="text/javascript" src="__PUBLIC__/hawk/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/frame/layui/layui.js"></script>
    <script>
              // 刷新
        $('#btn-refresh').on('click', function () {
            location.reload();
        });
    layui.use(['layer','layedit', 'laydate'], function(){
          var layer = layui.layer
          ,layedit = layui.layedit
          ,laydate = layui.laydate;
        //查看客户详情
        $(document).on('click','.more',function(){
            var cid=$(this).attr('cid');
            layer.open({
              type: 2,
              title:'客户详细信息',
              area: ['900px', '600px'],
              fixed: false, //不固定
              maxmin: true,
              content: '/index.php/Hawk/Service/moreInfo/id/'+cid
            });
        });
        //标记客户
        $(document).on('click','#defriend',function(){
          var id = $(this).attr('cus_id');
          var status = $(this).attr('status');
          var $this = $(this);
          $.post('/index.php/Hawk/Service/defriend',{'id':id,'status':status},function(data){
            var obj = eval('(' + data + ')');
            if(obj.code==1){
              layer.msg(obj.msg);
              if(status==1){
                $this.parent().parent().removeClass('defriend');
                return false;
              }
              if(status==0){
                $this.parent().parent().addClass('defriend');
                return false;
              }             
            }else{
              layer.msg(obj.msg);
            }
          });
        });
        
    });
    
    </script>
